<template>
	<view class="pet_deta">
		<view class="close" @click="$emit('close')">
			<image :src="`${baseImageUrl}/common/close1.png`"></image>
		</view>
		<view class="title">
			<view>
				<image :src="`${baseImageUrl}/common/zw.png`"></image>
				<text>宠物信息</text>
				<image :src="`${baseImageUrl}/common/zw.png`"></image>
			</view>
		</view>
		<view class="cover">
			<!-- <image :src="`${baseImageUrl}/test/2.png`"></image> -->
			<image :src="cover"></image>
		</view>
		<view class="name">【{{name}}】</view>
		<view class="progress_box">
			<view class="key">生命值：</view>
			<view class="progress_view">
				<view class="progress" :style="{width:width+'%'}"></view>
				<view class="text">{{health}}/100</view>
			</view>
		</view>
		<view class="sub_title">
			<image :src="`${baseImageUrl}/home/xs.png`"></image>
			<text>宠物技能</text>
			<image :src="`${baseImageUrl}/home/xs.png`"></image>
		</view>
		<scroll-view scroll-x class="scroll_view">
			<view class="item" v-for="item in list">
				<view class="item_box">
					<view class="cover">
						<image :src="item.skill.img"></image>
					</view>
					<view class="text">{{item.skill.name}}</view>
				</view>
			</view>
		</scroll-view>
		<view class="btn_view" v-if="type==1">
			<view class="confirm" @click="$emit('cancel')">取消出售</view>
		</view>
	</view>
</template>

<script>
	import {
		skillInfo
	} from '@/request/api.js';
	export default {
		props: {
			id: {
				type: [String, Number],
				default: ""
			},
			type: {
				type: [String, Number],
				default: 1
			}
		},
		data() {
			return {
				cover: "",
				name: "",
				health: "",
				width: 0,

				status: null,
				list: []
			}
		},
		async created() {
			let {
				pet,
				skill
			} = await skillInfo({
				id: this.id
			});

			this.cover = pet.product_cover;
			this.name = pet.product_name;
			let health = this.health = pet.health;
			this.width = health > 100 ? 100 : health;
			this.status = pet.status;
			this.list = skill;
		}
	}
</script>

<style scoped lang="scss">
	.pet_deta {
		width: 688rpx;
		height: 1000rpx;
		padding: 45rpx 44rpx 75rpx;
		box-sizing: border-box;
		background: url(#{$baseImageUrl}/bg/688_1000.png) no-repeat;
		background-size: 100% 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		position: relative;

		.close {
			width: 122rpx;
			height: 122rpx;
			position: absolute;
			right: 0rpx;
			top: 0rpx;
			transform: translate(25rpx, -50rpx);
			z-index: 2;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.title {
			display: flex;
			justify-content: center;
			align-items: center;

			view {
				height: 30rpx;
				display: flex;
				align-items: center;

				image {
					width: 30rpx;
					height: 30rpx;
				}

				text {
					color: #494338;
					font-size: 42rpx;
					font-weight: 400;
					font-family: LiSu;
					margin: 0 10rpx;
				}
			}
		}

		.cover {
			width: 260rpx;
			height: 260rpx;
			background: url(#{$baseImageUrl}/home/pet.png) no-repeat;
			background-size: 100% 100%;
			display: flex;
			justify-content: center;
			align-items: center;

			image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 50%;
			}
		}

		.name {
			color: #494338;
			font-size: 50rpx;
			font-weight: 400;
			font-family: LiSu;
		}

		.progress_box {
			width: 100%;
			display: flex;
			align-items: center;

			.key {
				color: #494338;
				font-size: 42rpx;
				font-weight: 400;
				font-family: LiSu;
				padding-right: 16rpx;
				box-sizing: border-box;
			}

			.progress_view {
				flex: 1;
				height: 25rpx;
				background: #B4A88E;
				box-shadow: 0px 0px 4px 0px rgba(110, 93, 72, 0.67);
				position: relative;

				.text {
					width: 100%;
					height: 25rpx;
					line-height: 25rpx;
					text-align: center;
					color: #494338;
					font-size: 24rpx;
					font-weight: 400;
					font-family: SimSun;
					box-sizing: border-box;
					position: absolute;
					left: 0;
					top: 0;
					z-index: 2;
				}

				.progress {
					// width: 30%;
					height: 100%;
					background: linear-gradient(90deg, #E68B30, #FAD44C);
				}
			}
		}

		.sub_title {
			width: 600rpx;
			height: 70rpx;
			background: url(#{$baseImageUrl}/bg/title.png) no-repeat;
			background-size: 100% 100%;
			display: flex;
			justify-content: center;
			align-items: center;

			text {
				color: #494338;
				font-size: 32rpx;
				font-weight: 400;
				font-family: SimSun;
				margin: 0 15rpx;
			}

			image {
				width: 20rpx;
				height: 20rpx;
			}
		}

		.scroll_view {
			white-space: nowrap;

			.item {
				display: inline-block;
				margin-right: 12rpx;

				.item_box {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;


					.cover {
						width: 80rpx;
						height: 80rpx;
						background: url(#{$baseImageUrl}/common/add_bg.png) no-repeat;
						background-size: 100% 100%;
						display: flex;
						justify-content: center;
						align-items: center;

						image {
							width: 50rpx;
							height: 50rpx;
						}
					}

					.text {
						color: #333333;
						font-size: 20rpx;
						font-family: SimSun;
						font-weight: 400;
						margin-top: 10rpx;
					}
				}

				&:last-child {
					margin: 0;
				}
			}
		}

		.btn_view {
			width: 100%;
			display: flex;
			justify-content: center;

			view {
				width: 210rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				color: #FFFFFF;
				font-size: 30rpx;
				font-weight: 400;
				margin: 0 40rpx;
			}

			.cancel {
				background: url(#{$baseImageUrl}/common/btn3.png) no-repeat;
				background-size: 100% 100%;
			}

			.confirm {
				background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
				background-size: 100% 100%;
			}
		}
	}
</style>